Skip to content

fix(di): accept DeviceType subtypes during device discovery#4033

Merged
marcschier merged 1 commit into
OPCFoundation:masterfrom
MrAlaskan:fix/discovery-device-subtypes
Jul 20, 2026
Merged

fix(di): accept DeviceType subtypes during device discovery#4033
marcschier merged 1 commit into
OPCFoundation:masterfrom
MrAlaskan:fix/discovery-device-subtypes

Conversation

@MrAlaskan

Copy link
Copy Markdown
Contributor

Summary

This PR makes DiDiscoveryClient.EnumerateDevicesAsync() accept DeviceType subtypes instead of requiring an exact type-definition match and adds regression tests that verify derived device types are discovered while non-device objects remain filtered out.

Problem

In OPC UA DI, device instances may be modeled directly as DeviceType or as instances of any subtype derived from DeviceType. A discovery helper that claims to enumerate DeviceType devices therefore needs to follow the OPC UA type hierarchy instead of requiring an exact TypeDefinition match.

Previously, DiDiscoveryClient.BrowseForDevicesAsync() identified devices with a direct comparison against DeviceType. As a result, any server that exposed devices through a legal subtype of DeviceType would have those devices treated as non-device objects, causing them to be skipped or only used as recursion points instead of being returned as discovered devices.

Changes

  • Replace the exact DeviceType comparison in BrowseForDevicesAsync() with a real subtype check based on session.NodeCache.IsTypeOfAsync(...).
  • Preserve the existing recursive browse behaviour for non-device objects.
  • Add regression coverage that verifies exact DeviceType instances still work, derived device types are now discovered, and non-device objects are still excluded.

@marcschier

Copy link
Copy Markdown
Collaborator

/azp run

@marcschier marcschier added the ready Ready to merge once CI Passes label Jul 19, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.53%. Comparing base (84fa8e8) to head (05c5dd5).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4033      +/-   ##
==========================================
- Coverage   73.85%   73.53%   -0.33%     
==========================================
  Files        1345     1345              
  Lines      179988   180046      +58     
  Branches    31668    31678      +10     
==========================================
- Hits       132938   132400     -538     
- Misses      36299    36935     +636     
+ Partials    10751    10711      -40     
Files with missing lines Coverage Δ
src/Opc.Ua.Di.Client/DiDiscoveryClient.cs 74.56% <100.00%> (+1.91%) ⬆️

... and 50 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@marcschier
marcschier merged commit f6ae61c into OPCFoundation:master Jul 20, 2026
165 of 166 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Ready to merge once CI Passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants